package com.xyf.sys.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author R-H
 * @Date 2024/3/81849
 * @Description
 */
@ConfigurationProperties("miniprogram")
@Configuration
@Data
public class MiniprogramConfig {

    public String clientAppid;

    public String clientSecret;

    public String manageAppid;

    public String manageSecret;

    public String serveAppid;

    public String serveSecret;

    @Bean(name = "clientConfig")
    public MiniConfig clientConfig(){
        return new MiniConfig(clientAppid, clientSecret);
    }

    @Bean(name = "manageConfig")
    public MiniConfig manageConfig(){
        return new MiniConfig(manageAppid, manageSecret);
    }

    @Bean(name = "serveConfig")
    public MiniConfig serveConfig(){
        return new MiniConfig(serveAppid, serveSecret);
    }

    @Data
    public class MiniConfig {
        private String appid;

        private String secret;

        public MiniConfig(String appid, String secret) {
            this.appid = appid;
            this.secret = secret;
        }
    }
}
